﻿layui.use(['form', 'layer', 'jquery', 'laypage'], function () {
    var form = layui.form,
		layer = parent.layer === undefined ? layui.layer : parent.layer,
		laypage = layui.laypage,
		$ = layui.jquery;
  
  
    $(function () {
        var state = $("#State").text();
        if (state == "False") {
            $("#State").text("未完成");
        } else {
            $("#State").text("已完成");
        }
        form.on('submit(Edit)', function (data) {
            $.ajax({
                type: "post",
                url: "/TasksManagement/Edit",
                data: data.field,
                dataType: "json",
                success: function (result) {
                    if (result.State == 1) {
                        layer.alert(result.Message, { icon: 1, time: 1.5 * 1000 });
                        location.href = "/TasksManagement/Tasks_Show";
                    }
                    else
                        layer.msg(result.Message, { icon: 7 });
                }
            });
           
            return false;
        });
        $(document).on("click", "#Cancel", function () {
            location.href = "/TasksManagement/Tasks_Show";
        });
    });

});